var fs=require('fs');
var args=process.argv.slice(2);
var cmd=args.shift();
var filePath='./.tasks';

switch(cmd){
    case 'list':
        fs.readFile(filePath,'utf8',function (err, data) {
            if(err)return '';
            //var list=data.split('\r\n');
            console.log('Task List:');
            console.log(data);
        });
        break;

    case 'add':
        var task=args.shift();
        fs.appendFile(filePath,task+'\r\n',function () {
            console.log(arguments);
        });
        break;

    default:
        console.log('Usage: '+process.argv[0] + ' list | add [task]');
}